#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/socket.h>

void error_handling(char *message) {
    fputs(message, stderr);
    fputc('\n', stderr);
    exit(1);
}

int main(int argc, char **argv) {
    int tcp_sock = socket(PF_INET, SOCK_STREAM, 0);
    int snd_buf, rcv_buf;
    int sock_type;
    socklen_t len;
    int state = getsockopt(tcp_sock, SOL_SOCKET, SO_SNDBUF, (void *)&snd_buf, &len);
    if (state)
        error_handling("get_opt error!\n");
    
    len = sizeof(rcv_buf);
    state = getsockopt(tcp_sock, SOL_SOCKET, SO_RCVBUF, (void *)&rcv_buf, &len);
    if (state)
        error_handling("get_opt error!\n");
    printf("Input buffer size: %d \n", rcv_buf);
    printf("Output buffer size: %d \n", snd_buf);
    return 0;
}